package com.jic.product.impl;

import java.lang.Long;
import java.util.List;


import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.product.entity.ProductSku;
import com.jic.product.mapper.ProductSkuMapper;
import com.jic.product.service.ProductSkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 商品SKU表
 * @author : 
 * @email : 
 * @since : 2020-02-06 01:47:28
 * @version : v1.0.0
 */
@Service
public class ProductSkuServiceImpl implements ProductSkuService {

    @Autowired
    private ProductSkuMapper productSkuMapper;

    @Override
    public long insert(ProductSku productSku) {
        long flag = productSkuMapper.insert(productSku);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return productSkuMapper.delete(id);
    }

    @Override
    public long update(ProductSku productSku) {
        return productSkuMapper.update(productSku);
    }

    @Override
    public ProductSku queryByPrimaryKey(Long id){
        return productSkuMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<ProductSku> query(ProductSku productSku){
        return productSkuMapper.query(productSku);
    }

    @Override
    public PageResult<ProductSku> queryPage(ProductSku productSku, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<ProductSku> list = productSkuMapper.queryPage(startIndex, pageQuery.getLimit(), productSku);
        long count = productSkuMapper.queryPageCount(productSku);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}